package com.legend.ddz.framework.impl;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;

import android.content.res.AssetManager;
import android.os.Environment;

import com.legend.ddz.util.CustomAssetsManage;

/**
 * 
 * @author zhugh
 * @date 2012-7-21 下午2:29:07
 * @description TODO
 * 
 */

public class AndroidFileIO implements FileIO
{
	AssetManager assetManager;
	String externalStoragePath;
	
	public AndroidFileIO(AssetManager paramAssetsManage)
	{
		this.assetManager = paramAssetsManage;
		String str1 = String.valueOf(Environment.getExternalStorageDirectory().getAbsolutePath());
		StringBuffer localStringBuffer = new StringBuffer(str1); 
		this.externalStoragePath = File.separator;
		
	}

	@Override
	public InputStream readAsset(String paramString) throws IOException
	{ 
		return this.assetManager.open(paramString);
	}

	@Override
	public InputStream readFile(String paramString) throws IOException
	{ 
	    return new FileInputStream(String.valueOf(this.externalStoragePath)+paramString);
	}

	@Override
	public OutputStream writeFile(String paramString) throws IOException
	{ 
	    return new FileOutputStream(String.valueOf(this.externalStoragePath)+paramString);
	}

}

